﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Satates.CMStates;

namespace Operators.CMOperators
{
    public class Move2CanibalLeft : iOperator
    {
        public override string ToString()
        {

            return "Move 2 Canibal Left";
        }
        public object Clone()
        {
            return this.MemberwiseClone();
        }
        public int getOperatorNumber()
        {
            return 3;
        }
        public Common.Template execute(Common.Template t)
        {
            CMState s2 = (CMState)t;
            s2.setLeftCanibals(s2.getLeftCanibals() + 2);
            s2.setRightCanibals(s2.getRightCanibals() - 2);
            s2.setBoat("left");
            return s2;
        }

        public bool available(Common.Template t)
        {
            CMState s = (CMState)t;
            if (s.getBoat().Equals("right"))
                if (s.getRightCanibals() >= 2)
                    if ((s.getLeftCanibals() + 2 <= s.getLeftMissionaries()) || (s.getLeftMissionaries() == 0))
                        return true;
            return false;
        }
    }
}
